These string methods will be on the AP exam for computer science.

To create a string:

String hotJapanese = newString("oguri-shun");
you can also create this by typing:
String hotJapanese = "oguri-shun";

Strings are, technically, like a class. They are an array of single letters.

hotJapanese.compareTo(rocklee);
this compares "oguri-shun" and "rocklee" alphabetically. It returns a negative number because "o" comes before "r" in the alphabet
if hotJapanese was compared to a word that comes before "oguri-shun" alphabetically, then it would return a positive number.


hotJapanese.indexOf(shun); This returns the slot in the array where the first letter (in this case, "s") is being searched for. This would have returned 6.

hotJapanese.length(); This gives the length of the array. It would return 10 in this case.

hotJapanese.substring(6);
This returns the string starting at the index and goes all the way to the end. In this case it would return: shun.
hotJapanese.substring(2, 6);
This returns the string starting at the first number in the parenthesis and ends the number before the last number in the parenthesis.
In this case it would return:
uri-**. Notice it does not return: ori-s because it stops at the fifth slot.